//自变量 json  经常用在数据解析
var student={
    id:10001,
    name:"张三",
    scores:[
        {subject:"html",score:90},
        {subject:"js",score:90}
    ]
}
console.log(student.id)
// student.id;
//构造函数  function
function student(id,name){
    this.id=id;
    this.name=name;
    this.scores=[
        {subject:"html",score:90},
        {subject:"js",score:90}
    ]
}

student.prototype.sex="男";
student.prototype.eat =function(food){
    console.log("吃"+ food)
}
var stu =new student(1001,"张三");
stu.eat("米饭");
// stu.scores;
console.log(stu.sex)

// object  代码重复率太高  灵活 扩展
 var stu2= new Object();
 stu2.id=1001;
 stu2.name="张三";
stu2.scores =[
    {subject:"html",score:90},
    {subject:"js",score:90}
]
console.log(stu2.scores)
//  属性 id name scores 
function student(id,name){
    this.id=id;
    this.name=name;
    this.eat =function(food){
        console.log("吃"+ food)
        console.log(this)
        return this// this 指41行student
    },
    this.sleep =function(){
        console.log("睡")
        return this //调用之后返回stud 
    }
}
var stud =new student(1001,"lisi");
stud.eat("22");
stud.sleep();//有stud. 可以调用后面函数
stud.eat("33").sleep().eat("55")//没有return 无法完成 因为没有返回到stud

//链式编程  jquery就是链式编程